/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


//--------------HANDLEBARS TEMPLATE INJECTION-------------------------
    function includes(tmpl_name, tmpl_data, target)
    {

        var tmpl_dir = "/FoodBasketApp/templates";
        var tmpl_url = tmpl_dir + "/" + tmpl_name + ".html";
        //console.log("template url>>> "+tmpl_url);
        var tmpl_string;

        $.ajax({
            url: tmpl_url,
            method: 'GET',
            async: false,
            success: function(data) {
                tmpl_string = data;
            }
        });
        
        //console.log("template_data>>>> "+tmpl_string);

        var hFunction = Handlebars.compile(tmpl_string);
        
        $(target).html(hFunction(tmpl_data));
        //$(target).html("hello world");

    }
//--------------END HANDLEBARS INJECTION-------------------------------

Handlebars.registerHelper('isAuthenticated', function(context, options){
    var result = $.cookie('verified');
    
    if(result!=null && result=='true')
        return options.fn(this);
    else
        return options.inverse(this);    
});

